<template>
<div class="header">
    <div class="left">
        <i class="iconfont icon-logo"></i>
        <span>机器学习 • 实验工作台</span>
    </div>
    <div class="right">
        <el-select clearable v-model="projectName" filterable placeholder="请选择项目">
            <el-option v-for="(item, i) in projectList" :key="i" :label="item.name" :value="item.value"></el-option>
        </el-select>
        <div class="help-doc" @click="handleToHelp">
            <i class="el-icon-question"></i>
            帮助文档
        </div>
        <avatar username="Jane Doe" :size="40"></avatar>
        <el-dropdown>
            <span class="el-dropdown-link">
          用户昵称<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>用户信息</el-dropdown-item>
                <el-dropdown-item @click.native="handleSignout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown>
    </div>
</div>
</template>

<script>
import Avatar from 'vue-avatar'
export default {
    name: 'HeadNav',
    components: {
        Avatar
    },
    data () {
        return {
            projectName: '',
            projectList: [
                { name: '项目0', value: '0' },
                { name: '项目1', value: '1' },
                { name: '项目2', value: '2' },
                { name: '项目3', value: '3' },
                { name: '项目4', value: '4' }
            ]
        }
    },
    methods: {
        handleSignout () {
            localStorage.setItem('token', '')
            this.$router.push('/login')
        },
        handleToHelp () {
            this.$message.error('该功能尚未开发，敬请期待')
        }
    }
}
</script>

<style lang="less">
.header {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .help-doc {
        margin: 0 30px;
        color: #ffffff;
        cursor: pointer;
        display: flex;
        align-items: center;
        font-size: 12px;
        i {
            font-size: 20px;
            color: #ffffff;
        }
    }

    .el-dropdown {
        margin-left: 15px;

        span {
            color: #ffffff;
        }
    }

    .left {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        height: 100%;

        i {
            font-size: 40px;
            color: #ffffff;
        }

        span {
            margin-left: 40px;
            color: #ffffff;
            font-size: 18px;
        }
    }

    .right {
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        height: 100%;
    }
}
</style>
